﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TEAA
{
    public class ParserRegularExpressions
    {

        public const string ATTRIBUTE_VALUE = "@" + ATTRIBUTE;

        public const string LOGICAL_OPERATORS = "(<|>|<=|>=|==|!=)";

        public const string JOIN_OPERATOR = "(=)";

        public const string TABLE = "([a-zA-Z][a-zA-Z0-9]*)";

        public const string ATTRIBUTE = "(" + TABLE + "(\\.[a-zA-Z][a-zA-Z0-9]*)?)";

        public const string TEXT_OR_CHARACTER = "('[a-zA-Z0-9]*')";

        public const string NUMBER_SIGN = "([-]?)";

        public const string INTEGER_NUMBER = "([0-9]+)";

        public const string DECIMAL_NUMBER = "((\\." + INTEGER_NUMBER + ")?)";

        public const string SELECT = "select[ ]+(" + ATTRIBUTE + "[ ]*,[ ]*)*" + ATTRIBUTE + "[ ]*";

        public const string FROM = "from[ ]+(" + TABLE + "[ ]*,[ ]*)*" + TABLE + "[ ]*";

        public const string WHERE = "where[ ]+(" +
            "(" + ATTRIBUTE + "[ ]*" + JOIN_OPERATOR + "[ ]*" + ATTRIBUTE + "[ ]*,[ ]*)|" +
            "((" + TEXT_OR_CHARACTER + "|" + ATTRIBUTE + ")[ ]*" + LOGICAL_OPERATORS + "[ ]*(" + TEXT_OR_CHARACTER + "|" + ATTRIBUTE + ")[ ]*,[ ]*)|" +
            "(((" + NUMBER_SIGN + INTEGER_NUMBER + DECIMAL_NUMBER + ")|" + ATTRIBUTE + ")[ ]*" + LOGICAL_OPERATORS + "[ ]*((" + NUMBER_SIGN + INTEGER_NUMBER + DECIMAL_NUMBER + ")|" + ATTRIBUTE + ")[ ]*,[ ]*)" +
            ")*(" +
            "(" + ATTRIBUTE + "[ ]*" + JOIN_OPERATOR + "[ ]*" + ATTRIBUTE + ")|" +
            "((" + TEXT_OR_CHARACTER + "|" + ATTRIBUTE + ")[ ]*" + LOGICAL_OPERATORS + "[ ]*(" + TEXT_OR_CHARACTER + "|" + ATTRIBUTE + "))|" +
            "(((" + NUMBER_SIGN + INTEGER_NUMBER + DECIMAL_NUMBER + ")|" + ATTRIBUTE + ")[ ]*" + LOGICAL_OPERATORS + "[ ]*((" + NUMBER_SIGN + INTEGER_NUMBER + DECIMAL_NUMBER + ")|" + ATTRIBUTE + "))" +
            ")";

    }
}
